import request from '@/api/request'
import { IaddCartData } from '@/types/goods'
import { IorderList } from '@/types/order'

// 购物车列表
export const cartList = () => {
    let include = "goods"
    return request.get('/api/carts',{params:{include}})
}


// 添加购物车
export const addCart = (list:IaddCartData) => {
    return request.post('/api/carts',list)
}
// 购物车改变选中
export const cartCheck = (cart_ids:number[]) => {
    return request.patch('/api/carts/checked',{cart_ids})
}
// 购物车数量改变
export const changeCartNum = (cart:number,num:number) => {
    return request.put('/api/carts/'+cart,{num})
}


// 生成订单
export const createOrder = () => {
    return request.get('/api/orders/preview')
}
// 提交订单
export const referOrders = (address_id:number) => {
    return request.post('/api/orders',{address_id})
}
// 订单列表
export const orderList = (list:IorderList) => {
    return request.get('/api/orders',{params:list})
}
// 订单详情
export const orderDetail = (order:number,list:object) => {
    return request.get('/api/orders/'+order,{params:list})
}


// 获取支付二维码
export const payCode = (order:number,list:object) => {
    return request.get(`/api/orders/${order}/pay/`,{params:list})
}